<template>
    <div class="wy-main business-car-manage">
     <!-- <a-row class="wy-main-title">
       <a-col :span="24">
				<p class="title-p">
					<a-divider class="title-vertical"  type="vertical" />
					<span class="title-span" >线路审核</span>
					<a-divider class="title-divider"  />
				</p>
			</a-col>
	 </a-row> -->
     <div class="my-main-cont" style="margin-left: 30px">
         <a-input v-model="certificatesNo" placeholder="请输入证件号码" style="width: 200px"/>
         <a-button type="primary" style="margin-left: 10px;" @click="getDriverinfo">查询</a-button>
		 <a-button style="margin-left: 15px;" @click="react">重置</a-button>
         <a-button class="title-button" type="primary" @click="seeAllInfo()">批量审核</a-button>
         <a-table :columns="columns" :dataSource="cardata" @change="handleTableChange" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" :rowKey="record => record.driverId" :pagination="pagination" :loading="loading" style="margin-top: 20px" >
					 <span slot="certificatesType" slot-scope="text, record">
		         <span v-if="record.certificatesType==0">身份证</span>
						 <span v-if="record.certificatesType==1">护照</span>
		        </span>
					 <span slot="approvalStatus" slot-scope="text, record">
                <a v-if="record.authenticationStatus==119" href="javascript:;" @click="edit(record)">待认证</a>
                <a v-if="record.authenticationStatus==120" href="javascript:;" @click="edit(record)">认证成功</a>
                <a v-if="record.authenticationStatus==121" href="javascript:;" @click="edit(record)">认证失败</a>
		     </span>
         </a-table>
          <div style="margin-top: -50px">
            <a-button @click="delAll">删除所选</a-button>
          </div>
     </div>
		 <a-modal :title="type == 'edit' ? '驾驶员审核' : '驾驶员审核'" :visible="visible" @cancel="handleCancel" width="900px" :maskClosable='false' :footer="null" >
			<credit-add v-if="visible" :datail='datail' @close="close" :type='type'></credit-add>
		</a-modal>
      <a-modal title="驾驶员审核" :visible="visibleAll"  @cancel="handleCancel"  width="900px" :maskClosable='false' :footer="null" >
           <credit-add-all v-if="visibleAll" @cancel="handleCancel" :datailAll='datailAll'></credit-add-all>
        </a-modal>
    </div>
</template>
<script>
import creditAdd from './CreditAdd'
import creditAddAll  from './CreditAddAll'
const columns = [{
		title: '姓名',
		dataIndex: 'driverName',
		key: '2',
	}, {
		title: '证件类型',
		dataIndex: 'certificatesType',
		scopedSlots: {
			customRender: 'certificatesType'
		},
		key: '3',
	}, {
		title: '证件号码',
		dataIndex: 'certificatesNo',
		key: '4',
	}, {
		title: '手机号',
		dataIndex: 'mobile',
		key: '5',
	}, {
		title: 'QQ',
		dataIndex: 'qq',
		scopedSlots: {
			customRender: 'qq'

		},
		key: '6'
	}, {
		title: '居住地址',
		dataIndex: 'address',
		key: '7',
	},{
		title: '操作',
		dataIndex: 'authenticationStatus',
		scopedSlots: {
			customRender: 'approvalStatus'
		},
	}];
const rowSelection = {
  onChange: (selectedRowKeys, selectedRows) => {
    console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
  },
  onSelect: (record, selected, selectedRows) => {
    console.log(record, selected, selectedRows);
  },
  onSelectAll: (selected, selectedRows, changeRows) => {
    console.log(selected, selectedRows, changeRows);
  },
};
export default {
    data() {
        return {
				 certificatesNo:'',
         cardata:[],
				 columns,
				 datail: {},
         type:'',
				 visible:false,
         visibleAll:false,
				 loading: false,
         rowSelection,
         selectedRowKeys: [],
        pagination: {
          pageSizeOptions: ['10', '20', '30', '40', '100'],
          defaultCurrent: 1,
          defaultPageSize: 10,
          total:10,
          showSizeChanger: true,
          showTotal: (total, range) => `共 ${total} 条记录`
        },
        }
    }, 
    created() {
      this.getDriverinfo()
		},
		components: {
			creditAdd,
      creditAddAll
		},
    methods: {
			// 修改完成关闭查询
			close(){
				this.visible = false
				this.getDriverinfo()
			},
			//关闭弹窗
			handleCancel() {
				this.visible = false
        this.visibleAll = false
        this.getDriverinfo()
        this.selectedRowKeys=[];
			},
			//编辑人员信息
			edit(data){
				this.type = 'edit'
				this.visible = true
				this.datail = data
			},
      seeAllInfo(){
        if(this.selectedRowKeys.length){
            this.visibleAll = true;
            let logIds = [];
           for(var i=0;i<this.selectedRowKeys.length;i++){
            logIds.push({"driverId":this.selectedRowKeys[i]})
           }
            this.datailAll = logIds;
          }else{
            this.$message.success('请选择需要审核的驾驶员!')
          }
      
      },
      onSelectChange (selectedRowKeys) {
          console.log('selectedRowKeys changed: ', selectedRowKeys);
          this.selectedRowKeys = selectedRowKeys
        },
			//删除
			delAll() {
				this.$confirm({
					title: '确定删除所选中的记录？',
					content: '当您点击确定按钮后，这些记录将会被彻底删除',
					centered: true
				})
			},
			//重置
			react(){
				this.pagination.defaultCurrent = 1;
				this.certificatesNo = ''
				this.getDriverinfo()

			},
      //获取驾驶人信息列表
      getDriverinfo(params={}){
				this.loading = true
				params.pageSize = this.pagination.defaultPageSize
				params.pageNum = this.pagination.defaultCurrent
				params.certificatesNo = this.certificatesNo
				this.$get('/info/infoDriver', {
          pageSize: this.pagination.defaultPageSize,
          pageNum: this.pagination.defaultCurrent,
          certificatesNo:this.certificatesNo
        }).then((r) => {
					console.log(r)
					this.loading = false
					this.cardata = r.data.data.rows
					this.pagination.total = r.data.data.total
				})
			},
          // 表格排序 分页 筛选事件
      handleTableChange(pagination, filters, sorter) {
         this.pagination.defaultPageSize = pagination.pageSize
         this.pagination.defaultCurrent  = pagination.current
         this.getDriverinfo();
        // this.getcarSource({
        //   ...this.queryParams
        // })
      },

      

    }
}
</script>
<style lang="less">
</style>